#include "../head.h"


// 阻塞程序  直到获取到信号
// int pause(void);

void sighandler1(int arg)
{
    printf("捕捉到信号 arg:%d\n", arg);
}

int main()
{
    printf("main\n");

    pid_t pid = fork();

    if (pid == 0)
    {
        signal(SIGINT, sighandler1);
        printf("child\n");
        pause();
        printf("child end\n");
        exit(0);
    }
    
    if (pid > 0)
    {
        sleep(3);
        kill(pid, SIGINT);

        sleep(3);
        kill(pid, SIGKILL);
    
        int status;
        wait(&status);
        printf("%d  %d %d %d\n", WIFEXITED(status), WEXITSTATUS(status), WIFSIGNALED(status), WTERMSIG(status));
    }
    


}